package com.xinhe.web.reposity;

import com.xinhe.web.entity.LocalUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;


public interface LocalUserRepository extends JpaRepository<LocalUser, Long> {
    @Query(value = "select * from tb_local_user where removed = 0 and username = ?1 and password = ?2", nativeQuery = true)
    LocalUser findByUsernameAndPassword(String username, String password);
    @Modifying
    @Query(value = "update tb_local_user set removed = 1 where f_user_id = ?1", nativeQuery = true)
    void deleteByUserId(Long userId);
    @Query(value = "select * from tb_local_user where removed = 0 and username = ?1", nativeQuery = true)
    LocalUser findOneByUsername(String username);
}